package com.tfriend.framework.xml;

import java.util.Iterator;
import java.util.Map;

public class Row {
	private String n= "";
	private String type="";
	private Map cols = new CaseInsensitiveHashMap();

	public String getN() {
		return n;
	}

	public void setN(String n) {
		this.n = n;
	}

	public String getType() {
		return nvl(type);
	}

	public void setType(String type) {
		this.type = type.toUpperCase();
	}

	public Map getCols() {
		return cols;
	}

	public void addCol(Col col) {
		this.cols.put(col.getName(), col);	
	}
	
	public String[] getColNames() {
		return getMapKeys(cols);
	}
	
	public Col getCol(String name) {
		return (Col)cols.get(name);

	}
	
	public int getColSize() {
		return cols.size();
	}
	
    static String[] getMapKeys(Map map) {
        if (map == null) {
            return null;
        }
        String[] ret = new String[map.size()];
        int inc = 0;
        for (Iterator i = map.keySet().iterator(); i.hasNext();) {
            ret[inc++] = (String) i.next();
        }

        return ret;
    }
    
    String nvl(String param) {
    	return param != null ? param : "";
    }
}
